<template>
  <el-drawer
    :visible.sync="drawer"
    direction="rtl"
    size="50%"
    :with-header="false"
    :width="700"
    :append-to-body="true"
  >
    <div class="drawer_box">
      <div class="drawer_title">
        <div class="drawer_t">
          <div class="drawer_t_l">
            <img
              class="drawer_t_l_img"
              src="/static/skin/herodoo/main/platform/home/img/piliangoumai.png"
              alt=""
            />
            添加打卡点
          </div>
          <img
            class="drawer_t_r"
            src="/static/skin/herodoo/main/platform/home/img/guanbi.png"
            alt=""
            @click="drawer = false"
          />
        </div>
      </div>
      <div class="drawer_content">
        <div class="list-box">
          <div class="small"></div>
          <div class="big">打卡点名称</div>
          <div class="big">打开点标签</div>
        </div>
        <el-checkbox-group v-model="checkList" @change="change">
          <div class="list-box check" v-for="item in list" :key="item.ID">
            <div class="small">
              <el-checkbox
                :checked="item.checked"
                :value="item.ID"
                :label="item.ID"
              ></el-checkbox>
            </div>
            <div class="big">{{ item.Name }}</div>
            <div class="big">{{ item.Address }}</div>
          </div>
        </el-checkbox-group>
      </div>
      <div class="button_list">
        <button @click="save()">保存</button>
      </div>
    </div>
  </el-drawer>
</template>

<script>
export default {
  name: "point",
  components: {},
  props: {
    // isEdit: {
    //   type: Boolean,
    //   default: true
    // }
  },
  data() {
    return {
      octopus: this.$parent.octopus,
      drawer: false,
      list: [],
      checkList: [],
      selectData: []
    };
  },
  created() {
    this.api_1292();
  },
  watch: {},
  methods: {
    drawerOpen(data = null, type = "CREATE") {
      this.drawer = true;
      //   this.isEdit = type;
      if (!data) {
        return;
      }
      this.list.map(v => {
        v.checked = false;
        let find = data.find(x => x.PointID == v.ID)
        if (find) {
          v.checked = true;
          v.x = find.x
          v.y = find.y
        }
      });
      // this.selectData = this.list;
    },
    change(e) {
      this.selectData = [];
      e.map(v => {
        this.selectData.push(this.list.find(x => v == x.ID));
      });
    },
    save() {
      this.$emit("getList", this.selectData);
      this.drawer = false;
    },
    api_1292() {
      this.octopus.request.api.post(
        "/Octopus/Engine/List",
        {
          id: 1292,
          cellData: [
            { name: "Name" }, // 打卡点位名称
            { name: "Address" }, // 打卡点地址
            { name: "UpdateUserIDName" }, // 操作人
            { name: "UpdateTime", width: 150 }, // 操作时间
            { name: "TypeIDName", show: false }, // TypeIDName
            { name: "Description", show: false }, // 点位详情
            { name: "ID", show: false }, // ID
            { name: "Scope", show: false }, // 打卡直径
            { name: "UpdateUserID", show: false }, // 操作人
            { name: "XAxis", show: false }, // x坐标
            { name: "YAxis", show: false }, // y坐标
            { name: "ImageUrl", show: false }, //
            { name: "TypeID", show: false } // TypeID
          ],
          paramData: {
            CompanyID:
              this.octopus.passport.authorization.company == 1
                ? "NULL"
                : this.octopus.passport.id
          }
        },
        data => {
          if (data.status.code == 200) {
            data.content.queryData.map(v => {
              v.checked = false;
              v.x = 0;
              v.y = 0;
            });
            this.list = data.content.queryData;
          } else {
            this.octopus.tips.error(data);
          }
        }
      );
    }
  }
};
</script>
<style scoped>
.drawer_box {
  padding: 3rem 0.8rem 3rem 0;
  height: calc(100% - 5rem);
  display: flex;
  flex-direction: column;
}

.drawer_title {
  box-shadow: 0px 5px 5px rgb(230 228 228 / 30%);
  padding-bottom: 1rem;
  font-size: 1.6rem;
}

.drawer_t {
  padding: 0 2.8rem;
  display: flex;
  justify-content: space-between;
}

.drawer_t_l {
  display: flex;
  align-items: center;
  font-size: 2rem;
  font-weight: bold;
}

.drawer_t_l_img {
  width: 2.8rem;
  margin-right: 1rem;
}

.drawer_t_r {
  width: 3rem;
  height: 3rem;
  cursor: pointer;
}

.button_box {
  margin-top: 1rem;
  padding: 0 3rem;
  display: flex;
}

.drawer_content {
  overflow-y: auto;
  margin-top: 1.5rem;
  height: calc(100vh - 11rem);
  padding: 0 3rem;
  width: 100%;
  padding-bottom: 1rem;
}

.drawer_content .title {
  font-size: 1.8rem;
  font-weight: bold;
}

.drawer_content .driver-title {
  margin-top: 1em;
}

.content-box {
  display: flex;
  align-items: center;
  margin: 2rem 0 2rem 2em;
}

.mt-10 {
  margin-top: 10rem;
}

.content-box .label {
  width: 25%;
  font-size: 1.6rem;
}

.content-box .label .label-bold {
  font-size: 1.8rem;
  font-weight: bold;
}

.content-box .desc {
  flex: 1;
  font-size: 1.6rem;
}

.list-box {
  display: flex;
  width: 100%;
  justify-content: space-between;
}

.list-box {
  line-height: 4rem;
  margin-top: 2rem;
}

.list-box .left {
  width: 20%;
  font-size: 1.5rem;
}

.list-box .right {
  width: 80%;
}

.button_list {
  margin-top: 1rem;
  display: flex;
  justify-content: end;
  position: absolute;
  background-color: #ffff;
  bottom: 1rem;
  width: calc(100% - 7rem);
}

.button_list button {
  border: none;
  height: 4rem;
  width: 12rem;
  border-radius: 1rem;
  margin-left: 1rem;
  color: #ffff;
  background-color: #f78c53;
  cursor: pointer;
}

.list-box .right .add_content {
  height: 4.5rem;
  line-height: 4.5rem;
  border: 1px dashed #f87338;
  display: inline-block;
  padding: 0 1.5rem;
  cursor: pointer;
  border-radius: 0.5rem;
}
.check {
  font-size: 1.5rem;
}
.small {
  width: 3vw;
}
.big {
  width: 20vw;
}
.small >>> .el-checkbox__label {
  display: none;
}
</style>
